<template>
  <a-modal v-model="visible"   title="编辑污染大类"  @cancel='cancel' @ok='sure'>
    <a-form-model :model="item" :label-col="{span :4 }" :wrapper-col="{ span: 20 }" style="margin-top: 20px">
      <a-form-model-item label="污染大类" required>
        <a-input v-model="item.polluteName"/>
      </a-form-model-item>
      <a-form-model-item label="优先级" required>
        <a-input v-model="item.pollutePriority"/>
      </a-form-model-item>
    </a-form-model>
  </a-modal>
</template>

<script>
import EpaSortService from '@/myService/EpaSortService'

export default {
  name: 'EditPolluteSubclassModal',
  data(){
    return{
      visible:false,
      title:'',
      item:{
        polluteName:null,
        qx:null,
        pollutePriority:null,
      },
      flag:false,
    }
  },
  methods: {
    open(record) {
      this.item=record;
      this.visible=true;
    },
    async sure(){
      let flag=0;
      if(this.item.polluteName==null||this.item.pollutePriority==null){
        this.$message.error("修改项不能为空")
      }else{
        await EpaSortService.updataPollute(this.item).then((res)=>{
          console.log(res)
          flag=res.result
        })
        if(flag==1){
          this.$message.success("修改成功")

          this.visible=false
        }else{
          this.$message.error("修改失败")
        }
      }
      this.$emit('getPolluteList')
    },
    cancel(){
      this.visible=false
    }
  }
}
</script>

<style scoped>

</style>